package com.atguigu.mr.index;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * @description: xxx
 * @time: 2020-01-06 20:27
 * @author: baojinlong
 **/
public class OneIndexDriver {
    public static void main(String[] args) throws Exception {
        String[] testPath = new String[]{"E:/home/test/big-table/input/oneindex", "E:/home/test/big-table/output/oneindex"};
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(OneIndexDriver.class);

        job.setMapperClass(OneIndexMapper.class);
        job.setReducerClass(OneIndexReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        FileInputFormat.setInputPaths(job, new Path(testPath[0]));
        FileOutputFormat.setOutputPath(job, new Path(testPath[1]));

        // 7 提交job
        boolean result = job.waitForCompletion(true);
        System.out.println("程序退出结果是" + result);
        System.exit(result ? 0 : 1);
    }
}
